﻿using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MsTestUtilities.SolutionAnalysis
{    
    public class ItemGroup<T> : IEnumerable<T>
        where T : IItem
    {
        private IList<T> _items;

        public ItemGroup()
        {            
            _items = new List<T>();
        }

        public ItemGroup(IEnumerable<T> items)
        {
            _items = items as IList<T> ?? items.ToList();           
        }

        public IEnumerable<string> Includes
        {
            get { return _items.Select(i => i.Include); }
        }

        public void Add(T item)
        {
            _items.Add(item);
        }

        public IEnumerator<T> GetEnumerator()
        {
            return _items.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}
